package com.tien.dao.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.tien.dao.TestDao;
import com.tien.dao.mock.LemonDatabaseMock;
import com.tien.model.Admins;
import com.tien.model.Asset;
import com.tien.model.User;
import com.tien.model.rss.LemonFeed;

/**
 * 
 * @author tien
 * 
 */
@Component
public class TestDaoImpl extends BaseDaoImpl implements TestDao {
	@Override
	public String getRealData() {
		return new Date().toString();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.dao.TestDao#getAssets(java.lang.String)
	 */
	@Override
	public List<Asset> getAssets(String accountId, int start, int limit) {
		return LemonDatabaseMock.instance().getAssets("tien", start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.dao.TestDao#getAssertsCount(java.lang.String)
	 */
	@Override
	public int getAssertsCount(String accountId) {
		return LemonDatabaseMock.instance().getAssetsCount("tien");
	}

	/* (non-Javadoc)
	 * @see com.tien.dao.TestDao#getAssets(int, int)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Admins> getAssets(int start, int limit) {
		// TODO Auto-generated method stub
		String hql = "from Admins"	;
		return this.getEntitiesByHQL(hql, start, limit);
	}

	/* (non-Javadoc)
	 * @see com.tien.dao.TestDao#getAdminsCount()
	 */
	@Override
	public int getAdminsCount() {
		// TODO Auto-generated method stub
		String hql = "select count(*) from Admins";
		return Integer.parseInt(this.countEntitiesByHQL(hql).toString());
	}

	/* (non-Javadoc)
	 * @see com.tien.dao.TestDao#getLemonFeedList(java.lang.String)
	 */
	@Override
	public List<LemonFeed> getLemonFeedList(String userId) {
		// TODO Auto-generated method stub
		String hql = "from LemonFeed where userid="+userId;
		return this.getEntitiesByHQL(hql);
	}

	/* (non-Javadoc)
	 * @see com.tien.dao.TestDao#saveLemonFeed(java.lang.String)
	 */
	@Override
	public int saveLemonFeed(LemonFeed feed) {
		// TODO Auto-generated method stub
		LemonFeed lemonFeed = (LemonFeed)this.saveEntity(feed);
		return Integer.parseInt(lemonFeed.getId().toString());
	}

	@Override
	public void deleteLemonFeed(Integer id) {
		this.deleteEntityById(LemonFeed.class, Long.parseLong(id.toString()));
	}

	@Override
	public void saveUser(User user) {
		this.saveEntity(user);
	}

}
